package icu.sehnen.zuul.filter;//package icu.icu.sehnen.zuul.filter;
//
//import com.alibaba.fastjson.JSONObject;
//import com.netflix.zuul.ZuulFilter;
//import com.netflix.zuul.context.RequestContext;
//import com.netflix.zuul.exception.ZuulException;
//import icu.icu.sehnen.common.model.CommonResult;
//import org.springframework.stereotype.Component;
//
//import javax.servlet.http.HttpServletRequest;
//
//@Component
//public class LogFilter extends ZuulFilter {
//    @Override
//    public String filterType() {
//        return "pre";
//    }
//
//    @Override
//    public int filterOrder() {
//        return 0;
//    }
//
//    @Override
//    public boolean shouldFilter() {
//        RequestContext currentContext = RequestContext.getCurrentContext();
//        HttpServletRequest request = currentContext.getRequest();
//        String requestURI = request.getRequestURI();
//        System.out.println("shouldFilter");
////        返回false表示放行
//
//        return requestURI.startsWith("/api/s");
//
//    }
//
//    @Override
//    public Object run() throws ZuulException {
//        System.out.println("run");
//        RequestContext currentContext = RequestContext.getCurrentContext();
//        HttpServletRequest request = currentContext.getRequest();
//        String remoteAddr = request.getRemoteAddr();
//        String remoteHost = request.getRemoteHost();
//        String requestURI = request.getRequestURI();
//
//        if (requestURI.startsWith("/api/t")){
//            //currentContext.setResponsetatusCode(HttpStatus.SC_UNAUTHORIZED);
//            String method = request.getMethod();//方法额类型
//            System.out.println(remoteAddr+","+remoteHost+"访问了"+requestURI+"方法");
////            不放行
//            currentContext.setSendZuulResponse(false);
//	        currentContext.setResponseBody(JSONObject.toJSONString(
//            CommonResult.forbidden("")));
//        }
//        return null;
//    }
//}